package cn.com.cis.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum TemplateParamType {

	CONNECTION("connection", "连接"), 
	DATE("date", "日期"), 
	TIME("time", "时间"), 
	NUMBER("int", "数值"), 
	TEXT("text", "文本"), 
	SQL("sql", "SQL"),
	MULTITHREAD_TASK_SETTING("MultiThreadTaskSetting", "线程设置"),
	DEFAULT("text", "文本");
	
	private String typeName;
	private String humanReadableName;
	
	public static TemplateParamType fromString(String stringValue){
		for(TemplateParamType type : TemplateParamType.values()){
			if(type.getTypeName().equals(stringValue)){
				return type;
			}
		}
		
		return TemplateParamType.DEFAULT;
	}
	
	public static TemplateParamType fromHumanReadableName(String humanReadableName){
		for(TemplateParamType type : TemplateParamType.values()){
			if(type.getHumanReadableName().equals(humanReadableName)){
				return type;
			}
		}
		
		return TemplateParamType.DEFAULT;
	}
}
